package cn.jobstart.controller;

import cn.jobstart.dto.ResumeAssociationActivityDTO;
import cn.jobstart.dto.ResumeAssociationActivityPageDTO;
import cn.jobstart.es.service.IResumeEsService;
import cn.jobstart.export.ResumeAssociationActivityDomainExport;
import cn.jobstart.modelExt.ResumeAssociationActivityExt;
import cn.jobstart.pubInter.IBaseService;
import cn.jobstart.pubInter.exception.SkException;
import cn.jobstart.searchExt.ResumeAssociationActivitySearchExt;
import cn.jobstart.service.IResumeAssociationActivityService;
import cn.jobstart.vo.ResumeAssociationActivityDetailDomainVO;
import cn.jobstart.vo.ResumeAssociationActivityDetailVO;
import cn.jobstart.vo.ResumeAssociationActivityDomainVO;
import cn.jobstart.vo.ResumeAssociationActivityListVO;
import cn.jobstart.web.common.SkJsonResult;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashSet;
import java.util.Set;

/**
 * @author sunke
 * @Date 2023-09-06 15:00:21
 * @description ResumeAssociationActivityController      在校经历
 */
@Api(tags = "人才管理系统-在校经历相关", description = "在校经历相关接口")
@RestController(value = "resumeAssociationActivityRestfulController")
@RequestMapping("/resumeAssociationActivity/")
@Validated
public class ResumeAssociationActivityController extends ApiManageController<ResumeAssociationActivityDTO, ResumeAssociationActivityPageDTO, ResumeAssociationActivityExt, ResumeAssociationActivitySearchExt, ResumeAssociationActivityDomainVO, ResumeAssociationActivityDetailDomainVO, ResumeAssociationActivityDetailVO, ResumeAssociationActivityListVO, String> {

    @Resource(name = "resumeAssociationActivityService")
    private IResumeAssociationActivityService resumeAssociationActivityService;

    @Resource
    private IResumeEsService resumeEsService;


    @Override
    public void afterPostAdd(ResumeAssociationActivityDTO dto, ResumeAssociationActivityExt domain, ResumeAssociationActivityDetailVO resumeAssociationActivityDetailVO, HttpServletRequest request, HttpSession session) throws SkException {
        super.afterPostAdd(dto, domain, resumeAssociationActivityDetailVO, request, session);

        resumeEsService.publishAssociationActivityByResumeId(domain.getResumesId());

    }


    @Override
    public void afterPostMod(ResumeAssociationActivityDTO dto, ResumeAssociationActivityExt domain, SkJsonResult<ResumeAssociationActivityDetailVO> jsonResult, HttpServletRequest request, HttpSession session) throws SkException {
        super.afterPostMod(dto, domain, jsonResult, request, session);
        resumeEsService.publishAssociationActivityByResumeId(domain.getResumesId());
    }


    @Override
    public IBaseService<ResumeAssociationActivityExt, ResumeAssociationActivitySearchExt, String> getBaseService() throws SkException {
        return resumeAssociationActivityService;
    }

    @Override
    public String getBaseRoute() {
        return "/resumeAssociationActivity/";
    }

    /**
     * 当前模板名称
     *
     * @return
     */
    @Override
    public String getModelName() {
        return "在校经历";
    }

    @Override
    public Class exportExcelClass() {
        return ResumeAssociationActivityDomainExport.class;
    }

    @Override
    public Set<String> totalMapSet() {
        Set totalMapSet = new HashSet();
        totalMapSet.add("count(resume_association_activity.raa_id) as countNum");
        return totalMapSet;
    }


}